extends Node

var velocity: Vector2;
@onready var seconds : int = 0;

@onready var detection : Area2D = %pArea2D;
@onready var node_star : Node = %node_star;


func _ready():
			print(self.position)
			print(self.global_position)
			velocity.x = 300;


func _process(delta):
	seconds += delta * 100;
	var targetVec = node_star.position - self.position;
	var targetAngle = velocity.angle_to(targetVec);
	var angleDiff = (velocity.angle() - targetAngle);
	if(seconds % 50 == 0): 
		print(rad_to_deg(targetAngle));
	
	var angleSpd = 45 * delta;
	if(abs(angleDiff) > angleSpd):
		velocity = velocity.rotated(-angleSpd * sign(angleDiff));
	else:
		velocity = velocity.rotated(-angleDiff);
	self.position += velocity * delta;
	self.rotation = velocity.angle();
